package com.sunqizhong.mapper;

import com.sunqizhong.entity.Clazz;
import com.sunqizhong.entity.ClazzsQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzsMapper {

    /*
    * 列表查询
    * */
    //@Select("select * from clazz")
    List<Clazz> list(ClazzsQueryParam param);

    /*
    * 添加班级
    * */
    @Insert("INSERT into clazz(name,room,begin_date,end_date,master_id,subject) " +
            "values (#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject})")
    void add(Clazz clazz);

    /*
    * 根据id查询部门数据
    * */
    @Select("select id,name,room,begin_date,end_date,master_id," +
            "subject,create_time,update_time from clazz where id = #{id}")
    Clazz getById(Integer id);

    /*
    * 根据id更新部门数据
    * */
    @Update("update clazz set name =#{name},room = #{room},begin_date = #{beginDate}," +
            "end_date=#{endDate},master_id = #{masterId},subject=#{subject}," +
            "update_time = #{updateTime} where id = #{id}")
    void update(Clazz clazz);

    /*
    * 根据id删除部门数据
    * */
    @Delete("delete from clazz where id = #{id}")
    Integer delete(Integer id);

    @Select("select * from clazz")
    List<Clazz> selectAll();
}
